<?php

header('Content-type: text/html; charset=utf-8');

require_once dirname(__FILE__).'/cf/config.php';
require_once cf\Config::path.'param.php';
require_once cf\Config::path.'image.php';
require_once cf\Config::path.'api/page.php';
require_once cf\Config::path.'api/shop.php';
require_once cf\Config::path.'api/cart.php';

define('SMARTY_DIR','./smarty/');
require_once SMARTY_DIR . 'Smarty.class.php';

$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$smarty->addPluginsDir(cf\Config::path.'components');


date_default_timezone_set('UTC');
setlocale(LC_ALL,"en_US.utf8");

$smarty->assign('topMenu',cf\api\page\getTree());

$pageId = null;
$smarty->assignByRef('pageId',$pageId);

$cart = cf\api\cart\getList();
$smarty->assign('total_amount',$cart[0]['total_amount']);
$smarty->assign('total_price',$cart[0]['total_price']);

function show($template, $name, $crumbs=array(), $title='', $keywords='', $descr='')
{
	global $smarty, $lang;

	$smarty->assign('name',$name);
	$smarty->assign('crumbs',$crumbs);
	$smarty->assign('title',$title);
	$smarty->assign('keywords',$keywords);
	$smarty->assign('descr',$descr);
	
	$smarty->assign('tpl', "$template.tpl");

	$smarty->display('main.tpl');
}

?>